package fr.emse.tatiana.replayable.analysis;

import java.util.List;
import java.util.Set;

import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IContributionItem;
import org.eclipse.jface.action.IContributionManager;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Composite;

import fr.emse.tatiana.replayable.Anchor;
import fr.emse.tatiana.replayable.IReplayableModel;

public interface IAnalysis {

	/**
	 * Get the name of the analysis (filename and name of the facet)
	 * 
	 * @return
	 */
	public String getName();

	/**
	 * Test whether an event is enriched in the analysis (the event is identified by its Anchor)
	 * 
	 * @param anchor The 
	 * @return
	 */
	public boolean hasValueForAnchor(Anchor anchor);

	/**
	 * Get the facet value for a given anchor
	 * 
	 * @param anchor
	 * @return
	 */
	public Object getValueForAnchor(Anchor anchor);

	/**
	 * Get the text to display for the facet for a given anchor
	 * 
	 * @param anchor
	 * @return
	 */
	public String getTextValueForAnchor(Anchor anchor);

	/**
	 * Get the GUI widget to choose the enrichment value
	 * 
	 * @param parent
	 * @return
	 */
	public CellEditor getChooser(Composite parent);

	/**
	 * Enrich an event (defined by its anchor) with a given value
	 * 
	 * @param anchor
	 * @param value
	 */
	public void setValue(Anchor anchor, Object value);
	
	/**
	 * Enrich an event (defined by its anchor) with a given value
	 * 
	 * @param anchor
	 * @param value
	 */
	public void setMultiple(Set<Anchor> anchor, Object value);

	/**
	 * Get the set of events (defined by their anchors) which are enriched in this analysis
	 * 
	 * @return
	 */
	public Set<Anchor> getAnchors();
	
	/**
	 * Register as a listener for changes to this analysis
	 * 
	 * @param listener
	 */
	public void addAnalysisEventListener(AnalysisEventListener listener);

	/**
	 * Unregister as a listener to changes to this analysis
	 * 
	 * @param listener
	 */
	public void removeAnalysisEventListener(AnalysisEventListener listener);

	/**
	 * Save the analysis
	 */
	public void doSave();

	/**
	 * Save the analysis with a given name
	 * 
	 * @param analysisname
	 */
	public void doSave(String analysisname);

	/**
	 * Has the analysis been modified recently
	 * 
	 * @return
	 */
	public boolean isSaved();

	/**
	 * Has the analysis been saved to file at least once
	 * 
	 * @return
	 */
	public boolean hasAnalysisFile();

	/**
	 * Shouldn't really be here, but provides a hint at how wide the 
	 * column needs to be
	 * 
	 * @param col
	 * @return
	 */
	public int getWidth(int col);

	/**
	 * Get the background color for the facet which enriches a given event
	 * 
	 * @param anchor
	 * @return
	 */
	public Color getBackground(Anchor anchor);

	public IContributionItem getMenuManager(List list, IReplayableModel r);

}